package ConditionPackage;

import java.util.Set;

import SquarePackage.Square;

public class ComposedCondition implements Condition{
	/**
	 * @pre watch out if no Conditions are added this is just a defaultCondition
	 * default constructor, doenst have any conditions
	 */
	public ComposedCondition(){
		conditions.add((new DefaultCondition()));
	}
	/**
	 * creates a ComposedCondition with a set of conditions so we can create practically every predicate 
	 * @param conditions the set of predefined conditions
	 */
	public ComposedCondition(Set<Condition> conditions){
		setConditions(conditions);
	}
	private Set<Condition> conditions;
	/**
	 * the method that checks ALL the conditions within the Set
	 * @return True if all the Conditions are valid for this checkSquare
	 * @param CheckSquare,the Square to check
	 */
	@Override
	public boolean checkCondition(Square checkSquare) {
		for(Condition condition : getConditions()){
			if(!condition.checkCondition(checkSquare))
				return false;
				
		}
		return true;
	}
	/**
	 * getter for the set of conditions...
	 * @return a nonemptyset with conditions 
	 */
	public Set<Condition> getConditions() {
		return conditions;
	}
	/**
	 * a setter for the set of condition
	 * @param conditions the set we want to set
	 * @post the set will be set to the new set of conditions
	 */
	public void setConditions(Set<Condition> conditions) {
		this.conditions = conditions;
	}
}
